<?
/*
----------------------------------------------------------------------
file:	hcacti.php
time:	2008.09
author:	joecen
site:	http://www.joecen.com/hcacti/
----------------------------------------------------------------------
*/

if(!isset($_REQUEST['result']) || !isset($_REQUEST['host']) || !isset($_REQUEST['time'])) die("Not enough argument!");

include(dirname(__FILE__) . "/../include/global.php");
include_once($config["base_path"] . "/include/config.php");
include_once($config["base_path"] . "/lib/rrd.php");
include_once($config["base_path"] . "/lib/database.php");
include_once($config["base_path"] . "/hcacti/hc_config.php");
include_once($config["base_path"] . "/hcacti/hc_function.php");
?>

<?
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
$host_file = get_host_info($_REQUEST['host']);

$server_info = array();
$server_info = preg_split('/;/',$_REQUEST['result']);

foreach($server_info as $value){
	list($t_name, $t_value) = preg_split('/:/',$value);
	$rrd_update_array[$host_file[$t_name]["path"]]["local_data_id"] = $host_file[$t_name]["local_data_id"];
	$item_info = array();
	$item_info = preg_split('/,/',$t_value);
	foreach($item_info as $item_value){
		list($i_name, $i_value) = preg_split('/=/',$item_value);
		$rrd_update_array[$host_file[$t_name]["path"]]["times"][$_REQUEST['time']][$i_name] = $i_value;
	}
}

#print_r($rrd_update_array);

/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();
$rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);

#print $rrds_processed."\n";
db_close();
?>
